<template>
    <el-button class="mb5" style="float: right" type="primary" @click="getList">
        <template #icon>
            <i-ep-search/>
        </template>
        刷新
    </el-button>
    <el-table v-adaptive="280" :border="true" :data="labApplyList" :header-cell-style="$headerCellStyle"
              :stripe="true"
              highlight-current-row>
        <el-table-column fixed="left" label="明细" type="expand">
            <template #default="props">
                <div m="4">
                    <el-table :data="props.row.labItemVoList" :row-class-name="tableRowClassName"
                              :stripe="true" highlight-current-row>
                        <el-table-column fixed="left" width="100px"/>
                        <el-table-column fixed="left" label="项目代码" prop="itemCode" width="150px"/>
                        <el-table-column fixed="left" label="项目名称" prop="itemName" width="220px"/>
                        <el-table-column :align="'center'" fixed="left" label="收费标志" prop="chargeFlag"
                                         width="100">
                            <template #default="scope">
                                <dict-data-tag :options="dictDataMap['charge_flag_dict']"
                                               :value="scope.row.chargeFlag"/>
                            </template>
                        </el-table-column>
                        <el-table-column :align="'center'" fixed="left" label="确认标志" prop="confirmFlag"
                                         width="80">
                            <template #default="scope">
                                <dict-data-tag :options="dictDataMap['confirm_flag']"
                                               :value="scope.row.confirmFlag"/>
                            </template>
                        </el-table-column>
                        <el-table-column fixed="left" label="数量" prop="num" width="120px"/>
                        <el-table-column fixed="left" label="单价(元)" prop="price" width="120px"/>
                        <el-table-column fixed="left" label="总价(元)" prop="costs" width="120px"/>
                    </el-table>
                </div>
            </template>
        </el-table-column>
        <el-table-column :align="'center'" fixed="left" label="申请序号" prop="applyNo" width="100"/>
        <el-table-column :align="'center'" fixed="left" label="收费标志" prop="chargeFlag" width="120">
            <template #default="scope">
                <dict-data-tag :options="dictDataMap['charge_flag_dict']" :value="scope.row.chargeFlag"/>
            </template>
        </el-table-column>
        <el-table-column :align="'center'" fixed="left" label="确认标志" prop="confirmFlag" width="80">
            <template #default="scope">
                <dict-data-tag :options="dictDataMap['confirm_flag']" :value="scope.row.confirmFlag"/>
            </template>
        </el-table-column>
        <el-table-column :align="'center'" label="是否加急" prop="isUrgent" width="90">
            <template #default="scope">
                <dict-data-tag :options="dictDataMap['sys_yes_no']" :value="scope.row.isUrgent"/>
            </template>
        </el-table-column>
        <!--            <el-table-column :align="'center'" label="检验类别" prop="labTypeName"/>-->
        <el-table-column :align="'center'" :show-overflow-tooltip="true" label="症状" prop="symptom"
                         width="140"/>
        <el-table-column :align="'center'" label="体征" prop="sign" width="140"/>
        <el-table-column :align="'center'" :show-overflow-tooltip="true" label="临床诊断"
                         prop="clinicalDiag" width="180"/>
        <el-table-column :align="'center'" label="开单时间" prop="realDate" width="150">
            <template #default="scope">
                <span>{{ $parseTime(scope.row.realDate, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
            </template>
        </el-table-column>
        <el-table-column :align="'center'" label="确认人" prop="confirmUserName" width="100"/>
        <el-table-column :align="'center'" label="确认时间" prop="confirmDate" width="150">
            <template #default="scope">
                <span>{{ $parseTime(scope.row.confirmDate, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
            </template>
        </el-table-column>
        <el-table-column :align="'center'" label="开单科室" prop="applyDeptName"/>
        <el-table-column :align="'center'" label="执行科室" prop="implementDeptName"/>
    </el-table>
</template>

<script lang="ts" setup>
import {useUserStoreHook} from "@/store/modules/user.ts";
import {useDictStoreHook} from "@/store/modules/dict.ts";
import {listLabApply} from "@/api/patient/labApply.ts";

const useUserStore = useUserStoreHook();
// 登录用户信息
const userInfo = <UserInfoBusi>useUserStore.user.userInfo;
const {proxy} = getCurrentInstance() as any;
const currentSelectDept = proxy.$currentSelectDept
const dictStore = useDictStoreHook();
let dictDataMap = ref(
    dictStore.isTypeGetData(
        "charge_flag_dict", "sys_yes_no", "confirm_flag", 'charge_flag_dict'
    )
);

const props = defineProps({
    inoroutFlag: {
        type: String,
        default: "4"
    },
    confirmFlag: {
        type: String,
        default: ""
    }
})
const queryParams = ref<any>({
    patientId: "",
    clinicId: "",
    orgId: userInfo.orgId,
    name: "",
    itemName: '',
    inoroutFlag: props.inoroutFlag,
    confirmFlag: props.confirmFlag
})

const labApplyList = ref([]);


// 检验
function getLabApplyList(clinicId: string) {
    queryParams.value.clinicId = clinicId
    getList()
}

// 检验
function getList() {
    listLabApply(queryParams.value).then((response: any) => {
        labApplyList.value = response.data;
    });
}

const tableRowClassName = () => {
    return 'success-row'
}

defineExpose({
    getLabApplyList,
    getList
})

</script>

<style scoped>

</style>
